<!-- Horizontal Form -->
<div class="box box-info" id="cominfo-App">
    <div class="box-header with-border">
        <h3 class="box-title">公司信息</h3>
    </div>
    <!-- /.box-header -->
    <!-- form start -->
    <form class="form-horizontal">
        <div class="box-body">
            <div class="form-group">
                <label  class="col-sm-2 control-label">公司名称</label>
                <div class="col-sm-10">
                    <input type="text" name="name" class="form-control" v-model="aboutUsVo.name">
                </div>
            </div>
            <div class="form-group">
                <label  class="col-sm-2 control-label">公司地址</label>
                <div class="col-sm-10">
                    <input type="text" name="address" class="form-control"  v-model="aboutUsVo.address">
                </div>
            </div>
            <div class="form-group">
                <label  class="col-sm-2 control-label">手机</label>
                <div class="col-sm-10">
                    <input type="text" name="telephone" class="form-control"  v-model="aboutUsVo.telephone">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">邮箱</label>
                <div class="col-sm-10">
                    <input type="text" name="email" class="form-control"  v-model="aboutUsVo.email">
                </div>
            </div>
            <div class="form-group">
                <label  class="col-sm-2 control-label">电话</label>
                <div class="col-sm-10">
                    <input type="text" name="phone" class="form-control"  v-model="aboutUsVo.phone">
                </div>
            </div>
            <div class="form-group">
                <label  class="col-sm-2 control-label">简介</label>
                <div class="col-sm-10">
                    <textarea  name="aboutUs" cols="40" rows="4" class="form-control" v-model="aboutUsVo.aboutUs"></textarea>
                </div>
            </div>

        </div>
        <!-- /.box-body -->
        <div class="box-footer">
            <button type="button" class="btn btn-default btn-cancel" @click="docancel">取消</button>
            <button type="button" class="btn btn-info pull-right btn-save" @click="saveOrUpdateNews()">
                保存
            </button>
        </div>
        <!-- /.box-footer -->
    </form>
</div>
<script type="text/javascript">
    var cominfoApp = new Vue({
        el: "#cominfo-App",
        data: {
            aboutUsVo: {}
        },
        methods: {
            saveOrUpdateNews: function () {
                //添加数据
                let formData = new FormData();
                formData.append("name",this.aboutUsVo.name);
                formData.append("address",this.aboutUsVo.address);
                formData.append("telephone",this.aboutUsVo.telephone);
                formData.append("email",this.aboutUsVo.email);
                formData.append("phone",this.aboutUsVo.phone);
                formData.append("aboutUs",this.aboutUsVo.aboutUs);
                if (!formData) {
                    alert('获取表单数据异常!');
                    return;
                }
                //发起axios post 请求 ,向后端提交数据
                axios({
                    method: 'post',
                    url: "/f-infocompany/save",
                    data: formData
                }).then(res => {
                    let result = res.data;
                    if (result.state == 2000) {
                        alert('保存成功!');
                        $('#mainContentId').load("/sys/comInfo")
                    } else {
                        alert(result.message);
                    }
                })
            },
            docancel: function () {
                //跳转到首页
               location.href="/admin";
            }
        },
        mounted() {
            axios({
                url: '/f-infocompany/cominfo',
                method: 'get',
            }).then(function (response) {

                if(response.data.state==2000){
                    cominfoApp.aboutUsVo = response.data.data;
                }else{
                    alert(response.data.message);
                }

            })
        }
    })
</script>
    
    
    
    
    
    
    